<template>
  <div class="prize-phone-main">
    <ActivityPhonePreview :width="332">
      <div class="title">{{ title }}</div>
      <div class="phone">
        <div class="avatar"></div>
        <div style="height: 740px">
          <div class="time time-title">活动倒计时显示：00天00时00分00秒</div>
          <div class="desc">
            邀请<span style="color: #f32624">{{ helpTask[helpTask.length - 1]?.help_num }}</span>位好友可得全部奖品
          </div>
          <div class="box" :style="{ justifyContent: helpTask.length == 1 ? 'flex-end' : 'space-between' }">
            <div class="reward_box" v-for="(item, index) in helpTask" :key="item.help_num">
              <div :style="{ opacity: index == 0 ? 0 : 1 }" class="reward_img"></div>
              <div class="reward_num">{{ item.help_num }}人</div>
            </div>
          </div>
          <div class="center_btn"></div>
          <div class="content">
            <div class="content_t">
              <img class="image" src="@/assets/phonePreview/activityPhonePreview/groupFission/prize2.png"/>
              <span>奖品列表</span>
            </div>
            <el-scrollbar class="scrollbar">
              <template v-for="(item, index) in helpTask" :key="item.help_num">
                <div v-if="index != 0" class="item">
                  <el-image v-if="item.reward_type == 1" class="item_img" :src="item.reward_image" fit="cover">
                    <template #error>
                      <el-icon>
                        <icon-picture />
                      </el-icon>
                    </template>
                  </el-image>
                  <img
                    v-else
                    class="item_img"
                    src="@/assets/phonePreview/activityPhonePreview/groupFission/prize3.png"
                  />
                  <div class="text">
                    <p v-if="item.reward_type == 1">{{ item.reward_title }}</p>
                    <p v-else>红包奖励</p>
                    <p>{{ item.help_num }}人</p>
                  </div>
                  <div v-if="index == 1" class="btn"> 已领取 </div>
                  <div v-if="index == 2" class="btn btn2"> 领取 </div>
                  <div v-if="index > 2" class="btn btn3"> 领取 </div>
                </div>
              </template>
            </el-scrollbar>
          </div>
          <div class="contents" v-if="brush_set.length!=0">
            <div class="content_t">
              <div>活动规则：</div>
              <div v-for="(item,i) in brush_set" :key="i" style="margin:10px 0px">
                  <div ><span>{{i+1}}.</span>{{item}}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </ActivityPhonePreview>
  </div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { Picture as IconPicture, Plus } from '@element-plus/icons-vue'
import bus from '@/utils/bus'
import ActivityPhonePreview from '../index.vue'

const title = ref<any>('')

const brush_set = ref<any>([])

const helpTask = ref<any>([
  {
    reward_type: 1,
    reward_image: '',
    reward_title: '',
    help_num: 0
  },
  {
    reward_type: 1,
    reward_image: '',
    reward_title: '',
    help_num: 1
  }
])

const onTitle = (v: any) => {
  title.value = v
}

const onHelpTask = (v: any) => {
  helpTask.value = [
    {
      reward_type: 1,
      reward_image: '',
      reward_title: '',
      help_num: 0
    },
    ...v
  ]
}
const onBrushSet = (v: any) => {
  const message = {
    1: '助力者退群后扣除助力人数',
    2: '同一助力者只能为1人助力'
  }
  brush_set.value=v.map((val: any) => message[val] )
}
bus.off('phone')
bus.on('phone', onTitle)
bus.off('helpTask')
bus.on('helpTask', onHelpTask)
bus.off('brush_set')
bus.on('brush_set', onBrushSet)

</script>
<style lang="scss" scoped>
.prize-phone-main {
  .title {
    width: 100%;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #333;
    position: absolute;
    top: 0px;
    font-weight: 700;
    color: #333;
    z-index: 3;
    background: #fff;
    height: 42px;
    line-height: 42px;
    z-index: 99;
    border-bottom: 1px solid #f5f5f5;
  }
  .phone {
      width: 100%;
      position: relative;
      border-radius: 20px 20px 10px 10px;
      background: url('@/assets/phonePreview/activityPhonePreview/groupFission/activity_bg.png');
      background-repeat: no-repeat;
      background-position: 0px 42px;
      background-size: 100%;
      &::before {
        content: '';
        position: absolute;
        top: 165px;
        left: 0;
        right: 0;
        width: 100%;
        height: 85%;
        background: linear-gradient(180deg, #ff562c 0%, #eb2233 100%);
        box-shadow: inset 0px 6px 36px 0px #ffb1a3;
        border-radius: 26px 26px 15px 15px;
      }
      .box {
        position: absolute;
        top: 263px;
        left: 28px;
        z-index: 10;
        width: 322px;
        height: 36px;
        display: flex;
        justify-content: flex-end;
        .reward_box {
          z-index: 10;
          position: relative;
          .reward_img {
            width: 22px;
            height: 22px;
            z-index: 10;
            background: url('@/assets/phonePreview/activityPhonePreview/groupFission/prize.png');
            background-repeat: no-repeat;
            background-size: 100%;
          }
          .reward_num {
            padding-top: 4px;
            font-size: 10px;
            font-family: STHeitiSC-Medium, STHeitiSC;
            font-weight: 500;
            color: #969696;
          }
          &:last-child .reward_img {
            float: right;
          }
        }
        &::before {
          content: '';
          width: 40px;
          height: 10px;
          border-radius: 10px;
          background: #fb2021;
          position: absolute;
          top: 6px;
          left: 0px;
          z-index: 5;
        }
        &::after {
          content: '';
          width: 320px;
          height: 10px;
          border-radius: 10px;
          background: #ffe2bf;
          position: absolute;
          top: 7px;
          left: 0px;
          z-index: 4;
        }
      }
      .avatar {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: url('@/assets/smartMarketing/nomal_avatar.png');
        background-size: cover;
        background-position: center;
        position: absolute;
        top: 80px;
        left: 14px;
        &::after {
          content: '用户昵称';
          position: absolute;
          top: 25px;
          left: 70px;
          width: 70px;
          height: 100%;
          color: #fff;
          font-size: 16px;
        }
      }
      .top {
        position: absolute;
        top: 0px;
        font-size: 10px;
        font-weight: 700;
        width: 100%;
        height: 52px;
        border-radius: 20px 20px 0 0;
        line-height: 20px;
        text-align: center;
        background: #ffffff;
      }
     
      .time {
        position: absolute;
        top: 165px;
        left: 50%;
        width: 350px;
        height: 20px;
        padding: 5px 12px 0;
        text-align: center;
        background: #f7cc81;
        transform: translateX(-50%);
        border-radius: 0 0 16px 16px;
        font-size: 8px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #774a1c;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .time-title {
        width: 260px;
      }
      .desc {
        position: absolute;
        top: 230px;
        left: 50%;
        z-index: 10;
        width: 183px;
        height: 20px;
        padding-top: 5px;
        text-align: center;
        transform: translateX(-50%);
        border-radius: 0 0 15px 15px;
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #774a1c;
        font-weight: 600;
        &::before {
          content: ' ';
          position: absolute;
          top: 5px;
          left: -18px;
          width: 15px;
          height: 15px;
          color: #774a1c;
          background: url('@/assets/phonePreview/activityPhonePreview/groupFission/tips.png');
          background-size: 100%;
        }
        &::after {
          content: ' ';
          position: absolute;
          top: 5px;
          left: 184px;
          width: 15px;
          height: 15px;
          color: #774a1c;
          background: url('@/assets/phonePreview/activityPhonePreview/groupFission/tips.png');
          background-size: 100%;
        }
      }
      .progress {
        width: 277px;
        height: 10px;
        border-radius: 10px;
        background: #ffe2bf;
        position: absolute;
        top: 225px;
        left: 29px;
        z-index: 10;
        &::before {
          content: '0人';
          position: absolute;
          top: 18px;
          left: 0;
          font-size: 10px;
          font-family: STHeitiSC-Medium, STHeitiSC;
          font-weight: 500;
          color: #969696;
        }
        &::after {
          content: '2人';
          position: absolute;
          top: 18px;
          left: 77px;
          font-size: 10px;
          font-family: STHeitiSC-Medium, STHeitiSC;
          font-weight: 500;
          color: #969696;
        }
      }
      .progress_2 {
        width: 66px;
        height: 10px;
        border-radius: 10px;
        background: #fb2021;
        position: absolute;
        top: 225px;
        left: 29px;
        z-index: 10;
        &::before {
          content: '5人';
          min-width: 30px;
          position: absolute;
          top: 18px;
          left: 167px;
          font-size: 10px;
          font-family: STHeitiSC-Medium, STHeitiSC;
          font-weight: 500;
          color: #969696;
        }
        &::after {
          content: '10人';
          min-width: 30px;
          position: absolute;
          top: 18px;
          left: 252px;
          font-size: 10px;
          font-family: STHeitiSC-Medium, STHeitiSC;
          font-weight: 500;
          color: #969696;
        }
      }
      .reward_2 {
        left: 194px;
      }
      .reward_3 {
        left: 286px;
      }
      .center_btn {
        position: absolute;
        top: 214px;
        left: 13px;
        z-index: 3;
        background: #ffffff;
        width: 93%;
        height: 176px;
        border-radius: 8px;
        &::before {
          content: '邀请好友助力列表';
          position: absolute;
          top: 111px;
          left: 23px;
          z-index: 10;
          font-size: 14px;
          width: 300px;
          height: 38px;
          line-height: 38px;
          text-align: center;
          border-radius: 18px;
          background: #fb2021;
          color: #fff;
        }
      }
      .content {
        position: absolute;
        left: 12px;
        top: 410px;
        background: #ffffff;
        width: 350px;
        // height: 269px;
        border-radius: 8px;

        .content_t {
          padding: 10px;
          padding-bottom: 10px;
          border-bottom: 1px solid #f5f5f5;
          display: flex;
          align-items: center;
          font-size: 16px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #333333;
          .image {
            width: 16px;
            height: 16px;
            margin-right: 4px;
          }
        }
        .scrollbar {
          width: 350px;
          height: 235px;
          padding-right: 10px;
          border-radius: 0 0 8px 8px;
        }
        .item {
          padding: 7px;
          background: #fff;
          border-bottom: 1px solid #f5f5f5;
          border-radius: 8px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .text {
            flex: 1;
            padding: 4px 0;
            margin-left: 6px;
            p {
              height: 15px;
              font-size: 12px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #33302d;
            }
          }
          .btn {
            width: 50px;
            padding: 5px 0;
            background: #cccccc;
            border-radius: 15px;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            text-align: center;
            color: #ffffff;
            background: #cccccc;
          }
          .btn2 {
            background: #ffe7c7;
          }
          .btn3 {
            background: #ffbc1a;
          }
          .item_img {
            width: 36px;
            height: 36px;
            font-size: 36px;
            display: grid;
            place-items: center;
          }
        }
      }
    }
  
}
  .contents{
    position: absolute;
    left: 12px;
    top: 700px;
    background: #ffffff;
    width: 350px;
    font-size: 14px;
    border-radius: 8px;
    .content_t{
      padding: 10px;
    }
  }

</style>
